<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">

<body>

<div th:fragment="nav">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                        data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">ONE 社区</span>
                </button>
                <a href="/"> <img src="/images/logo.png" alt="logo" class="navbar-brand"></a>
            </div>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <form class="navbar-form navbar-left" action="/" method="GET">
                    <div class="form-group">
                        <input type="text" class="form-control" name="search" placeholder="搜索问题">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
                <ul class="nav navbar-nav navbar-right">
                    <li th:if=" ${session.user !=null}">
                        <a href="/publish" style="display: flex;flex-direction: row;align-items: center;justify-content: center;">
                            <span class="glyphicon glyphicon-plus-sign"></span>&nbsp;
                            <span>提问</span>
                        </a>
                    </li>
                    <li th:if="${session.user !=null}">
                        <a href="/profile/replies"
                           style="display: flex;flex-direction: row;align-items: center;justify-content: center;">
                            <span class="glyphicon glyphicon-bell"></span>&nbsp;
                            <span class="badge"
                                  style="background-color: #c7254e;color: white;font-size: 12px;" th:if="${session.unReadCount != 0}" th:text="${session.unReadCount}"></span>
                        </a>
                    </li>
                    <li th:if="${session.user !=null}">
                        <img th:src="${session.user.getAvatarUrl()}" class="img-circle img-avatar" alt="avatar">
                    </li>
                    <li class="dropdown" th:if="${session.user !=null}" role="presentation">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                           aria-expanded="false" th:text="${session.user.getName()}">
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/profile/questions">我的问题</a></li>
                            <li><a href="/profile/replies">最新回复</a></li>
                            <li><a href="/profile/information">个人资料</a></li>
                            <li><a href="/logout">退出登录</a></li>
                        </ul>
                    </li>

                    <li th:if="${session.user ==null}">
                        <a href="http://github.com/login/oauth/authorize?client_id=b3b546e022ca3539a8bb&redirect_url=http://localhost:8080/callback&scope=user&state=1">登录</a>
                    </li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>

</div>


</body>
</html>